﻿#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

void fun(char* p)
{
	p = (char*)malloc(strlen("hello") + 1);
	strcpy(p, "hello");
	//*p = '1';
	//p[0] = '1';
	*(p + 0) = '1';
	printf("fun  = %s\n", p);//fun  = 1ello
}

void fun2(int** p)
{
	*p = (int*)malloc(sizeof(int));
	**p = 100;
}

void fun3(int** p)
{
	int* tmp = (int*)malloc(sizeof(int));
	*tmp = 100;

	*p = tmp;
}

//main173：指针的复习
int main173()
{
	/*
	char* p = NULL;

	fun(p);
	printf("p = %s\n", p);//p = (null)
	*/

	/*
	int* p = NULL;
	fun2(&p);//地址传递

	printf("*p = %d\n", *p);//*p = 100
	*/

	int* p = NULL;
	fun3(&p);//地址传递

	printf("*p = %d\n", *p);// *p = 100

	system("pause");
	return EXIT_SUCCESS;
}